fix(cli): support build --from local paths#556
Conversation
Add local path handling for sh1pt build --from, including stack detection and summary output.
Adds coverage for local directory stack detection, packageManager handling, and missing local path errors.
Greptile SummaryThis PR adds support for
Confidence Score: 3/5The local-path feature itself works correctly, but the removal of goProjectName silently breaks project-name extraction for any Go module that uses a major-version path suffix. The Go versioned-module name regression is a real, present defect on the changed code path: any go.mod with a /v2 (or higher) suffix will display the version segment as the project name instead of the actual module name. packages/cli/src/commands/build.ts — specifically the Go stack-detection block and the unmigrated git summary branch Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[sh1pt build --from input] --> B{resolveInput}
B --> C{input.kind}
C -- git --> D[cloneAndDetect]
D --> D1[spawnSync git clone]
D1 --> D2[detectStack cloneDir]
D2 --> D3[printBuildSummary inline]
D3 --> D4{keepClone?}
D4 -- no --> D5[rmSync cloneDir]
D4 -- yes --> D6[return]
D5 --> D6
C -- path --> E[detectLocalPath NEW]
E --> E1{input.exists and existsSync?}
E1 -- no --> E2[throw: local path not found]
E1 -- yes --> E3{statSync.isDirectory?}
E3 -- no --> E4[throw: must be a directory]
E3 -- yes --> E5[detectStack dir]
E5 --> E6[printBuildSummary helper]
E6 --> E7[return]
C -- other --> F[stub log]
|
| runtime: 'go', | ||
| packageManager: 'go', | ||
| projectName: modName ? goProjectName(modName) : undefined, | ||
| projectName: modName ? modName.split('/').pop() : undefined, |
There was a problem hiding this comment.
Go versioned-module name regression
The deleted goProjectName helper explicitly stripped major-version path segments before calling .split('/').pop(). The new inline expression skips that step, so a Go module declared as module github.com/user/my-go-app/v2 now returns "v2" as the project name instead of "my-go-app". Any Go monorepo or library that follows the standard vN major-version suffix convention will produce a misleading project name in the build summary.
| it('throws when a local --from path is missing', () => { | ||
| const dir = join(makeTempDir(), 'missing'); | ||
|
|
||
| expect(() => detectLocalPath({ | ||
| kind: 'path', | ||
| raw: dir, | ||
| value: dir, | ||
| inferredName: 'missing', | ||
| exists: false, | ||
| })).toThrow('local path not found'); | ||
| }); |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
4 similar comments
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
Summary
sh1pt build --from <path>.Testing
Related to the CLI command implementation work requested in #133.